package com.igoal.service;

import java.util.Date;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.igoal.dto.UserActivityDTO;
import com.igoal.dto.UserActivityLogDTO;
import com.igoal.dto.WallActivityDTO;
import com.igoal.entity.ActionTypeEnum;
import com.igoal.entity.ComponentEnum;
import com.igoal.entity.PrivacySetting;
import com.igoal.entity.User;

/**
 * Log some user actions during using system and use that data for report and analysis
 * @author Tri
 *
 */
public interface ActionLoggerService {
	/**
	 * Log user {@link ActionTypeEnum} in a {@link ComponentEnum}
	 * @param componentOwner the component owner that is took action from other
	 * @param actionOwner the user that has an {@link ActionTypeEnum} to a {@link ComponentEnum}
	 * @param actionType {@link ActionTypeEnum}
	 * @param component {@link ComponentEnum}
	 * @param componentId component identifier
	 */
	@Transactional(readOnly=false)
	void log(User componentOwner, User actionOwner, ActionTypeEnum actionType, ComponentEnum component, Long componentId);

	@Transactional(readOnly=false)
	void log(User componentOwner, User actionOwner, ActionTypeEnum actionType, ComponentEnum component, Long componentId, PrivacySetting privacy);

	/**
	 * Get notifies of user.
	 * <p>When user component is took an action from people, a notify will be created.</p>
	 * @param ownerName component owner username
	 * @param lastItemUpdateDate last updated action Date
	 * @param before get notifies before or after <code>lastItemUpdateDate</code>
	 * @return list {@link UserActivityDTO}
	 */
	@Transactional(readOnly=true)
	List<UserActivityDTO> getNewNotificationsLog(String ownerName, Date lastItemUpdateDate, boolean before);
	
	/**
	 * Get activities of user and friends
	 * @param relatedUserName the user that his friends action will be list out
	 * @param isExceptRelateUser include this user actions or not
	 * @param lastItemUpdateDate last updated action Date
	 * @param before get notifies before or after <code>lastItemUpdateDate</code>
	 * @return list {@link UserActivityLogDTO}
	 */
	@Transactional(readOnly=true)
	List<UserActivityLogDTO> getNewActivitiesLog(String relatedUserName, boolean isExceptRelateUser, Date lastItemUpdateDate, boolean before);
	
	/**
	 * Count new notifies of user
	 * @param ownerName component owner username
	 * @param lastItemUpdateDate last updated action Date
	 * @param before get notifies before or after <code>lastItemUpdateDate</code>
	 * @return number of new notifies
	 */
	@Transactional(readOnly=true)
	int countNewNotificationLog(String ownerName, Date lastItemUpdateDate, boolean before);
	
	@Transactional(readOnly=true)
	List<WallActivityDTO> getWallActivities(String requestUser, String wallOwner, Long updateBefore);
}
